package com.ruoyi.fly.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.fly.domain.AppletProductOrder;
import com.ruoyi.fly.domain.vo.AppletProductOrderVo;
import com.ruoyi.fly.domain.vo.ProductOrderQueryVo;
import com.ruoyi.fly.domain.vo.ProductOrderVo;
import com.ruoyi.fly.service.AppletProductOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/productOrder")
@Api(tags = "产品订单管理")
public class AppletProductOrderController extends BaseController {

    @Autowired
    private AppletProductOrderService appletProductOrderService;

    /**
     * 查询产品订单列表
     */
    @ApiOperation(value = "查询产品订单列表")
    @PostMapping("/list")
    public TableDataInfo list(AppletProductOrder appletProductOrder) {
        startPage();
        List<ProductOrderVo> list = appletProductOrderService.selectAppletProductOrderList(appletProductOrder);
        return getDataTable(list);
    }


    /**
     * 根据产品订单id获取产品订单详细信息
     * @param id
     * @return
     */
    @ApiOperation(value = "根据产品订单id获取产品订单详细信息")
    @GetMapping(value = "/select/{id}")
    public R getInfo(@PathVariable("id") String id) {
        return R.ok(appletProductOrderService.selectAppletProductOrderById(id));
    }

    /**
     * 根据条件查询产品订单
     */
    //@ApiOperation(value = "根据条件查询产品订单")
    @PostMapping("/selectOrder")
    public R selectProductOrder(@RequestBody ProductOrderQueryVo productOrderQueryVo) {
        return R.ok(appletProductOrderService.selectAppletProductOrder(productOrderQueryVo));
    }



    /**
     * 添加快递单号
     * @param appletProductOrderVo
     * @return
     */
    @ApiOperation(value = "添加快递单号")
    @PostMapping("/add")
    public R edit(@RequestBody AppletProductOrderVo appletProductOrderVo) {
        return appletProductOrderService.updateAppletProductOrder(appletProductOrderVo);
    }

    /**
     * 删除产品订单
     * @param ids
     * @return
     */
    @ApiOperation(value = "删除产品订单")
    @PostMapping("/delete")
    public R remove(@RequestBody List<String> ids) {
        return appletProductOrderService.deleteAppletProductOrderByIds(ids);
    }
}
